//
//  RCtitleButton.m
//  RCsinaMicroBlog
//
//  Created by Mr.Ray on 15/2/1.
//  Copyright (c) 2015年 Ray.peng. All rights reserved.
//

#import "RCtitleButton.h"

@implementation RCtitleButton

// 通过代码创建控件时会调用
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}



// 通过xib/Storboard创建时调用
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup{
    //设置一次性属性
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
    //图片居中
    self.imageView.contentMode = UIViewContentModeCenter;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    
}

- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.titleLabel.x = self.imageView.x;
    self.imageView.x =CGRectGetMaxX(self.titleLabel.frame) +5;
}


@end
